EN FR
EN FR


Section: New Results

Loop Nests and Integer Polyhedra

Participant : Alain Ketterlin.

The polyhedral model has been found adequate to model a large number of program analyses and transformations. It has now been used for decades in automatic parallelization, locality optimization, high-level code synthesis, and other applications. Thanks to the availability of high-quality software tools, the polyhedral model is now widely used. However, we feel that some of its most fundamental operations need more thorough attention, and possibly new theoretical developments. Even though the translation of loop nests into polyhedra (or unions thereof) obviously use integers only, many algorithms still use an underlying rational (or real) domain. For instance, Fourier-Motzkin variable elimination is defined on rational domains, and its modern incarnation (the Omega test), uses convoluted and costly techniques to compensate for the mishandling of integer variables. When used for projection (for instance during code generation, i.e., turning polyhedra into loop nests), these defects lead to sub-optimal results, with programs including more control than necessary. Overall, we feel that current techniques are inadequate to capture the precise behavior of integer variables.

We have started investigating new representations for inequalities over integer variables, using a notation called “periodic numbers”. This notation was invented by Eugène Ehrhart in his classical results on the number of integer points inside integer polyhedra, and rediscovered and generalized by Philippe Clauss in his work on the use of counting for locality optimization and automatic parallelization. Periodic numbers capture all sorts of integer-specific behaviors: for instance, they are especially suitable to represent the seemingly chaotic structure of discrete line intersections, or the modular intersections of parallel hyper-planes. Periodic numbers also have algebraic properties that make them easy to manipulate and combine. We have defined a generalization of affine expressions where the constant term becomes a periodic number: it turns out that this family of expressions has interesting stability properties, that make them especially suitable for variable elimination. We have shown that most problems of Fourier-Motzkin variable elimination are related to the “looseness” of affine inequalities over integer variables, and that periodic numbers can correct this defect. The result is a new representation of inequalities, that makes reasoning with inequalities sound and complete.

An immediate application of our new representation is deciding whether a given integer polyhedron contains an integer point (or: whether a given set of affine constraints on integer variables is feasible). We have developed a straightforward version of Fourier-Motzkin elimination that is always exact. An interesting aspect of this work is that the algorithm is only a slight generalization of the original Fourier-Motzkin elimination, to cover the cases where inequalities have periodic components. We have also extended the basic algorithm to produce arbitrary projections of integer polyhedra. This improves over the Omega elimination strategy in that we are able to produce a provably disjoint union. These interesting properties derive directly from the use of periodic numbers.

Periodic numbers, and periodic linear inequalities, also have applications more directly related to the compilation of affine loop nests. For instance, we have developed a fully-general unswitching transformation. Unswitching a loop containing a conditional amounts to split the loop into one or more new loops such that the conditional has a constant truth value in all loop fragments, and can therefore be removed. The transformation is general in that the resulting program contains only affine loops and periodic linear conditionals. This means that the process can be repeated until obtaining a final version of the loop nest that is completely free of conditionals. We expect this “code generation” strategy, though naive, to remove enough “divergence” to increase existing and enable new applications of vectorization, leading to more efficient code. On the theory side, producing a conditional-free code scanning an arbitrary union of polyhedra has also direct consequences on various polyhedral operations: for instance, computing extrema becomes a trivial task, and linear optimization also falls under this umbrella. We hope to be able to explore these tracks in the near future.

We have developed software making use (and illustrating) our theoretical developments. We expect to share this software with select colleagues very soon, so as to be able to assess the scope of our techniques. Publication of these results is expected in the next year, time permitting. We also expect to extend our current software base to provide a range of integer polyhedra operations (images and pre-images, projection, and linear optimization, mostly). Finally, our middle-term goal is to investigate a formal modeling of the integer polyhedra operations. All algorithms have been kept as simple as possible, favoring elaborate abstractions over complex processing, with the goal of being able to formally specify the fundamental operations.